#include "widget.h"
#include "ui_widget.h"
#include<QButtonGroup>
#include<QDebug>
#include<QRegExpValidator>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    ui->pushButton->setEnabled(false);
    ui->lineEdit_name->setPlaceholderText("请输入姓名");
    ui->lineEdit_name->setClearButtonEnabled(true);

    ui->lineEdit_passwor->setPlaceholderText("请输入密码");
    ui->lineEdit_passwor->setClearButtonEnabled(true);
    ui->lineEdit_passwor->setEchoMode(QLineEdit::Password);

    ui->lineEdit_dianhua->setPlaceholderText("请输入电话");
    ui->lineEdit_dianhua->setClearButtonEnabled(true);
  //  ui->lineEdit_dianhua->setInputMask("000-0000-0000");

    QButtonGroup qbg;
    qbg.addButton(ui->radioButton);
    qbg.addButton(ui->radioButton_2);



    ui->lineEdit_dianhua->setValidator(new QRegExpValidator(QRegExp("^\\d{3}-\\d{3}-\\d{4}$")));




}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    if(ui->radioButton->isChecked())
    {
        qDebug()<<"性别:沃尔玛购物袋";
    }
    else
    {
        qDebug()<<"武装直升机";
    }
    qDebug()<<"姓名:"<<ui->lineEdit_name->text();
    qDebug()<<"密码:"<<ui->lineEdit_passwor->text();
    qDebug()<<"电话"<<ui->lineEdit_dianhua->text();


}

//void Widget::on_lineEdit_dianhua_textEdited(const QString &arg1)
//{

//}

void Widget::on_lineEdit_dianhua_textEdited(const QString &arg1)
{
    qDebug()<<arg1;
    int pos =0;
    QString s1 =arg1;
    if(ui->lineEdit_dianhua->validator()->validate(s1,pos)==QValidator::Acceptable)
    {
        ui->pushButton->setEnabled(true);
    }
    else
    {
        ui->pushButton->setEnabled(false);
    }
}
